package set;

import java.util.NavigableSet;
import java.util.Random;
import java.util.TreeSet;

public class TreeSetTest {
    public static void main(String[] args) {
        TreeSet<Integer> set = new TreeSet<>();
        Random random = new Random();
        for (int i = 0; i < 5; i++) {
            set.add(random.nextInt(10));
        }
        set.stream().forEach(item -> System.out.print(item + " "));
        System.out.println();

        NavigableSet<Integer> navigableSet = set.descendingSet();
        navigableSet.stream().forEach(item -> System.out.print(item + " "));
        System.out.println();
    }
}
